<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>计算</title>
 </head>
 <body>
 	<input type="text" id="number1"> +
	<input type="text" id="number2">
	<button onclick="result();">计算</button>
	<div>计算的结果为：<span id="result"></span></div>
	<script type="text/javascript">
		function result(){
			var num1 = document.getElementById("number1").value;
			if(isNaN(num1)){
				alert("您第一个文本中输入的不是数字型！");
				return ;
			}

			var num2 = document.getElementById("number2").value;
			if(isNaN(num2)){
				alert("您第二个文本中输入的不是数字型！");
				return ;
			}
			var t = parseFloat(num1)+parseFloat(num2);
			document.getElementById("result").innerHTML = t;
		}
	</script>
 </body>
</html>
